<template>
	<BaseContainer>
		<ProjectSelect belongProject="govBuyManage"></ProjectSelect>
		<aplid-base-crud ref="crud" class="w-100" v-bind="{ ...baseConfig, ...$attrs }" :paramsObj="{ type: 2 }">
      <template v-slot:menuRight>
        <ExportQrcode />
      </template>
			<template v-slot:menuColumn="{ row }">
				<el-button v-if="row.dataStatus && row.dataStatus !== '0'" @click="handleOperate('changeData', row, '数据变更')" text type="warning">
					变更中
				</el-button>
			</template>
			<template v-slot:addDialog="{ row, show }">
				<TabForm @refresh="handleRefresh" @operate="handleOperate" :api="baseConfig.api" :key="show" :nowRowData="row"> </TabForm>
			</template>
			<template v-slot:ArchivesDialog="{ row, show }">
				<Archives
					@refresh="handleRefresh"
					@refreshPage="handleRefreshPage"
					@rechange="handleOperate"
					:api="baseConfig.api"
					:key="show"
					:nowRowData="row"
				></Archives>
			</template>
			<template v-slot:importDialog="{ row, show }">
				<ImportForm @refresh="handleRefresh" :api="baseConfig.api" :key="show" :nowRowData="row"></ImportForm>
			</template>
			<template v-slot:qrcode="{ row }">
				<el-icon :size="44" color="#000" @click="handleOperate('viewCode', row, '查看二维码')">
					<icon-pay-code-one />
				</el-icon>
			</template>
			<template v-slot:changeDataDialog="{ row, show }">
				<RechangeDetail @refresh="handleRefresh" :api="baseConfig.api" :key="show" :batchNumber="row.dataStatus"></RechangeDetail>
			</template>
			<template v-slot:viewCodeDialog="{ row, show }">
				<QrcodeImg :text="row.idCard" v-if="show" :width="400"></QrcodeImg>
			</template>
		</aplid-base-crud>
	</BaseContainer>
</template>

<script setup lang="ts">
import { baseConfig } from './config'
import Archives from './Archives/index.vue'
import ImportForm from './ImportForm/index.vue'
import RechangeDetail from '@/views/datacenter/components/DataGather/change/detail.vue'
import TabForm from './TabForm/index.vue'
import ExportQrcode from './ExportQrcode/index.vue'
import QrcodeImg from '@/views/homeCare/components/QrcodeImg/preview.vue'
import ProjectSelect from '@/views/homeCare/components/ProjectSelect/index.vue'

const crud = ref()
const dialogVisible = ref(false)
const handleRefresh = (query, visible = false) => {
	dialogVisible.value = visible
	nextTick(() => {
		crud.value.refreshChange(query)
	})
}
const handleOperate = (type, row, title) => {
	nextTick(() => {
		crud.value.handleOperate(type, row, title)
	})
}
const handleRefreshPage = () => {
	nextTick(() => {
		crud.value.refreshChange({}, true)
	})
}

defineExpose({
	handleRefresh,
})
</script>

<style scoped></style>
